package 富婆梦.第一阶段.第三周.练习题;

public class SimpleDotCom {
    int[] locationCell;
    int numOfHit = 0;
    public String checkyoursel(String StringGuss){
        int guss = Integer.parseInt(StringGuss);
        String result = "miss";
        for (int cell:locationCell) {
            if (cell == guss){
                result = "hit";
                numOfHit++;
            }
        }
        if (numOfHit == locationCell.length){
            result = "sunk";
        }
        return result;
    }
    public void setLocationCell(int[] cell){
        this.locationCell = cell;
    }


    public static void main(String[] args) {
        SimpleDotCom dot = new SimpleDotCom();
        dot.test1(dot);

    }

    //测试射击动作
    public void test1(SimpleDotCom dot){
        int[] location = {2,3,4};
        dot.setLocationCell(location);
        String guss = "3";
        String result = dot.checkyoursel(guss);
        String testResult = "fail";
        if (result.equals("hit")){
            testResult = "pass";
        }
        System.out.println(testResult);
        System.out.println(Integer.parseInt("a"));
    }
}
